<template>
  <c-card title="科室均次统计报表">
    <div slot="title-left" class="title-left">
      <a-radio-group name="radioGroup" :options="options" :default-value="1"/>
      <div class="help">
        规则说明<img src="@/assets/images/question.png" alt="">
      </div>
    </div>
    <a-table class="custom"
             :columns="columns"
             :data-source="tableData"
             :pagination="{total,pageSize}"
             :scroll="{ y: '150px'}"
             @change="tableChange"
             :rowKey="e=>Math.random()">
      <a slot="operation">查看明细</a>
    </a-table>
  </c-card>
</template>

<script lang="ts">
import columns from '../assets/columns';
import {controlFeeFeeAvgList} from "@/api/drgsGroupResults.js"

export default {
  inject: {
    depCodeFormParent: {
      type: String,
      default: ""
    },
    getDepCodeFormParent: {
      type: Function,
      default: () => () => ""
    },
    timeParamsFormParent: {
      type: Object,
      default: () => ({})
    },
    getTimeParamsFormParent: {
      type: Object,
      default: () => () => ({})
    }
  },
  data() {
    return {
      total:0,
      pageSize:10,
      pageNum:1,
      options: [
        {value: 1, label: "全部科室(79)"},
        {value: 2, label: "红卡科室(40)"},
        {value: 3, label: "绿卡科室(39)"}
      ],
      columns,
      tableData: []
    }
  },
  computed: {
    reactiveGetDepCodeFormParent() {
      return this.getDepCodeFormParent();
    },
    reactiveGetTimeParamsFormParent() {
      return this.getTimeParamsFormParent();
    }
  },
  watch: {
    reactiveGetDepCodeFormParent: {
      handler() {
        this.getControlFeeFeeAvgList();
      },
      immediate: true
    }
  },
  created() {

  },
  methods: {
    tableChange(e){
      this.pageNum = e;
      this.getControlFeeFeeAvgList()
    },
    async getControlFeeFeeAvgList() {
      this.tableData = [];
      const params = {
        pageIndex: this.pageNum,
        pageSize: this.pageSize,
        depCode: this.reactiveGetDepCodeFormParent,
        year: this.reactiveGetTimeParamsFormParent.year,
        month: this.reactiveGetTimeParamsFormParent.month,
      }
      const res = await controlFeeFeeAvgList(params);
      if (res['data'] && res['data']['list'] && res['data']['list'].length) {
        this.tableData = res['data'].list;
        this.total = res['data']['total']
      }
    }
  }
}
</script>

<style scoped lang="stylus">

.title-left {
  margin-left 30px
  width 600px
  display flex
  align-items center

  .help {
    cursor pointer
    display flex
    align-items center
    font-size: 12px;
    color: #484D78;
    line-height: 12px;

    img {
      margin-left 5px
      width 14px
    }
  }

}
</style>
